<!--高危信号列表-->
<template>
<div class="page fireHazardList-page" data-page="fireHazardList"
	style="z-index: 2;">
	<div class="link-page-nav">
		<a href="#" class="link" @click="$root.backToTab()"> <i
			class="iconfont icon-zuo"></i>
		</a>
	</div>
	<div class="link-page-top" style="padding-bottom: 17px;">
		<div class="link-page-list-title">高危信号</div>
	</div>
	<div class="go-history-list">
		<a class="link" style="color: #000000;" @click="goToHistory"> <i
			class="iconfont icon-APPicon_lishi" style="font-size: 23px;"></i>
		</a>
	</div>
	<div class="link-page-tab" style="padding-left: 23px;">
		<div class="troubleApply-item-type" id="troubleApply-item-type_{{getNewId}}">
      <a href="#" class="col" @click="eachTypeFireHazard(1)"id="fireHazardList_no_{{getNewId}}">未处理</a>
      <a href="#" class="col" @click="eachTypeFireHazard(2)" id="fireHazardList_has_{{getNewId}}">已处理</a> 
      <a href="#" class="col" @click="eachTypeFireHazard(3)"  id="fireHazardList_all_{{getNewId}}">全部</a>
		</div>
	</div>
	<div class="page-content infinite-scroll-content"
		style="padding-bottom: 75px;">

				<div data-infinite-distance="55"	class="tab page-content infinite-scroll-content"	@infinite="loadMore">
					<div class="fireHazard-list">
						<ul id="highTiskList_{{getNewId}}" class="fireHazardList-list-item">
						</ul>
						<div id="fireHazardList_preloader_{{getNewId}}"	class="preloader infinite-scroll-preloader"></div>
					</div>
				</div>
	</div>
</div>
</template>
<script>
    return {
        mounted() {
            var self = this;
            self.tabId = self.$route.params.tabID;
            if (single_Orgid == "") {
              self.organizationIds=userInfor.organizationIds;
            } else {
              self.organizationIds=single_Orgid;
            }
        },
        data: function () {
            return {
              tabID:null,
              pageIndex:0,
              pageSize:25,
              isInfinite:true,
              organizationIds:"",
              tabId:"",
              noDealNum:"",
              hasDealNum:"",
              getNewId: (new Date()).getTime()
            }
        },
        methods: {
          backToRefresh:function(){
            var self = this;
            // var $ = self.$$;
            // $("#highTiskList_"+self.getNewId).empty();
            self.highRiskSignal()
            self.getHighRiskCountData_history();
            // self.showList();
          },
          highRiskSignal:function(){
            var self = this;
            let getAlarming = JSON.parse(localStorage.getItem("highRiskSignal"))
            let $ul = $("#highTiskList_"+self.getNewId).children()
            for(let i=0;i<$ul.length;i++){
              if(getAlarming.id == $ul.eq(i).attr("data-id") && getAlarming.handlerStatus == 1){
                $ul.eq(i).empty()
              }
            }
          },
            getHighRiskCountData_history:function(){
                var self = this;
                var $ = self.$$;
                Dao.getHighRiskCount({
                  userName: userInfor.accountName,
                  deviceId: appKeyObj.deviceId,
                  organizationIds:self.organizationIds
                },function(re){
                  $("#fireHazardList_no_"+self.getNewId).html("未处理 "+re.unHandlerCount);
                  $("#fireHazardList_has_"+self.getNewId).html("已处理 "+re.handlerCount);
                  $("#fireHazardList_all_"+self.getNewId).html("全部"+re.totalCount);
                });
            },
            goToHistory:function(){
              app.router.navigate("/fireHazardHistoryList/");
            },
            eachTypeFireHazard:function(tabId){
                var self = this;
                var $ = self.$$;
                $("#troubleApply-item-type_" + self.getNewId + " .col").removeClass('select').eq((tabId-1)).addClass('select');
                $("#highTiskList_"+self.getNewId).empty();
                $("#fireHazardList_preloader_"+self.getNewId).show();
                self.tabId = tabId;
                self.pageIndex=0;
                self.pageSize=25;
                self.isInfinite = true;
                $("#fireHazardList_preloader_"+self.getNewId).hide();
                self.showList();
            },
            showList:function(){
                var self = this;
                var $ = self.$$;
                var handlerStatus = "";
                if(self.tabId==1){
                  handlerStatus = 0;
                }else if(self.tabId==2){
                  handlerStatus = 1;
                }
                Dao.getHighRiskList({
                  userName: userInfor.accountName,
                  organizationIds:self.organizationIds,
                  isReset:0,
                  handlerStatus:handlerStatus,
                  startTimeStr:"",
                  endTimeStr:"",
                  queryType:1,
                  pageIndex:self.pageIndex,
                  pageSize:self.pageSize
                },function(data){
                  if(data && data.length>0){
                    //没分页
                    if(data.length<self.pageSize){
                      $("#fireHazardList_preloader_"+self.getNewId).hide();
                      self.isInfinite = false;
                    }else {
                      $("#fireHazardList_preloader_"+self.getNewId).show();
                      self.isInfinite = true;
                    }
                    for(var i=0;i<data.length;i++){
                      //表示未处理
                      if( data[i].handlerStatus==0){
                        $("#highTiskList_"+self.getNewId).append(`
                        <li class="highDager_detail" data-handlerStatus="`+data[i].handlerStatus+`" data-id="`+data[i].id+`" style="overflow:hidden">
                          <div class="highDanger-item-border">
                            <div class="highDanger-item-num">`+data[i].alertNum+`</div>
                            <div class="highDanger-item-name">火情数量</div>
                          </div>
                          <div class="highDanger-item-desc">`+data[i].selfDesc+`</div>
                          <div class="highDanger-item-unit-desc" ><i class="iconfont icon-APPicon_dingwei" style="color:#2471CA;margin-left:-3px;"></i><span class="highDanger-item-unit">`+common.transNullundefinedToline(data[i].organizationName)+`</span></div>
                          <div class="highDanger-item-interval-time">已持续`+data[i].intervalTime+`</div>  
                          <div class="highDanger-item-deal rightBtnCl" data-handlerStatus="`+data[i].handlerStatus+`" style="padding:5px 15px;color:#FFF;background:#4CA4FE;border-radius:15px;margin: 0 15px 10px;" data-id="`+data[i].id+`">立即处理</div>
                        </li>
                        `);
                       
                      }else{//已处理
                        $("#highTiskList_"+self.getNewId).append(`
                        <li class="highDager_detail" data-id="`+data[i].id+`">
                          <img class="highDanger-item-overtime-img" style="left:8%" src="/ilink-app-h5-zd/static/img/rdspFile_1554726645262.png"/>
                          <div class="highDanger-item-border">
                            <div class="highDanger-item-deal-num">`+data[i].alertNum+`</div>
                            <div class="highDanger-item-name">火情数量</div>
                          </div>
                          <div class="highDanger-item-desc">`+data[i].selfDesc+`</div>
                          <div class="highDanger-item-unit-desc"  ><i class="iconfont icon-APPicon_dingwei" style="color:#2471CA;margin-left:-3px;"></i><span class="highDanger-item-unit">`+common.transNullundefinedToline(data[i].organizationName)+`</span></div>
                          <div class="highDanger-item-interval-time">已持续`+data[i].intervalTime+`</div>  
                        </li>
                        `);
                      }
                      $(".highDager_detail").click(function(event) {
                          var id = jQuery(event.currentTarget).attr("data-id");
                          var handlerStatus = jQuery(event.currentTarget).attr("data-handlerStatus");
                          let data = {
                            id:id,
                            handlerStatus:handlerStatus
                          }
                          localStorage.setItem("highRiskSignal",JSON.stringify(data))
                          app.router.navigate("/fireHazardDetail/"+id+"/0/");
                      });
                    
                    }
                  }else{
                    if (self.pageIndex == 0) { //暂无数据
                        self.isInfinite = false;
                        $("#fireHazardList_preloader_"+self.getNewId).hide();
                        $("#highTiskList_"+self.getNewId).append(`<div class="no-data-img"><img src="`+listNoDataPic()+`"/></div>`);
                    }
                  }
                  jQuery('.rightBtnCl').off().click(function(event){
                        let id = jQuery(this).attr("data-id");
                        let handlerStatus = jQuery(this).attr("data-handlerStatus");
                        let data = {
                          id:id,
                          handlerStatus:handlerStatus
                        }
                        localStorage.setItem("highRiskSignal",JSON.stringify(data))
                        app.router.navigate("/fireHazardCancel/"+id+"/");
                        event.stopPropagation();
                      })
                });
            },
            //加载更多
            loadMore:function(){
               var self = this;
               if (self.isInfinite){
                  self.pageIndex++;
                  self.showList();
               }
            },
        },
        on: {
          pageInit: function (e, page) {
            var self = this;
            self.getHighRiskCountData_history();
            self.eachTypeFireHazard(self.tabId);
          }
        }
      }
</script>
<style scoped>
.triangle_right{
  float: right;
  margin-right: -78px;
  margin-top: 2px;
}
</style>